package org.example.io;

import java.io.File;
import java.io.FileWriter;

public class TestFileWriter {
    public static void main(String[] args) throws Exception{
        // 使用File对象创建流对象
        File file = new File("D:\\tmp\\111.txt");
        FileWriter writer = new FileWriter(file);
        // 使用文件名称创建流对象
        FileWriter fileWriter = new FileWriter("D:\\tmp\\111.txt");

        //写出字符数组
        char[] chars = {'从','处','开'};
        fileWriter.write(chars);
        //换行操作
        fileWriter.write("\r\n");
        //写入字符串
        fileWriter.write("从初夏时节开启的欧洲之行");

        //关闭输出流
        fileWriter.close();
        writer.close();
    }
}
